import { useEffect, useState } from 'react'

export const useScroll = (cb: Function) => {
    useEffect(() => {
      const handleScroll = (e: any) => {
        cb(e.srcElement.scrollingElement.scrollTop)
        
    }
    window.addEventListener('scroll', handleScroll)
    return () => {
      // 组件销毁时清除绑定事件
      window.removeEventListener('scroll', handleScroll)
    }
  }, [])
}
